/*
 * @Author: czy
 * @Date: 2021-05-19 21:30:58
 * @LastEditTime: 2021-06-01 19:55:57
 */
#ifndef __SYSTEM_H_
#define __SYSTEM_H_

#include "datetime.h"

#define WORD_SIZE 20
#define ENV_SIZE 1000
#define ALIGN 32

typedef signed short int int16;
typedef struct
{
    unsigned long head;
    unsigned long meta;
} Partition;
typedef struct
{
    unsigned long size;
    unsigned long previous;
    unsigned long next;
} Block;

void cls(int fd);
int getc(int fd);
int putc(int ch, int fd);
char *read(char *str, const char *promrt, int fd);
int write(char *buf, int fd);
void gotoxy(int x, int y, char *buf, int fd);

time_t gettime(void);
void settime(time_t time);
void timer(void (*func)(void), int interval);
void setTimeout(void (*func)(void), int interval);

int env(const char *name, char *value);
int export(const char *name, const char *value);
int set(const char *name, const char *value);

void shutdown(void);

unsigned long getMemStart(void);
unsigned long getMemSize(void);
void top(void);

unsigned long eFPartitionTotalSize(unsigned long perSize, unsigned long n);
unsigned long eFPartitionInit(unsigned long start, unsigned long perSize, unsigned long n);
unsigned long eFPartitionAlloc(unsigned long EFPHandler);
unsigned long eFPartitionFree(unsigned long EFPHandler, unsigned long mbStart);
unsigned long dPartitionInit(unsigned long start, unsigned long size);
unsigned long dPartitionAlloc(unsigned long dpHandler, unsigned long size);
unsigned long dPartitionFree(unsigned long dpHandler, unsigned long start);

#endif